<?php
	$name = $_POST['name'];
	include("conn.php");

	$stmt = $db->prepare('select * from check0 where name=?');
	$stmt->execute(array($name));
	$y=array();
	$result= $stmt->fetch(PDO::FETCH_ASSOC);

	$y=$result['address'];
	$path=$y;//路径
	$position='../存储文件/'.$result['name'];

	$stmt = $db->prepare('insert into file(name,year,uploadtime,subject,type,address) values(?,?,?,?,?,?)');
	$stmt->execute(array($result['name'],$result['year'],$result['uploadtime'],$result['subject'],$result['type'],$position));

	if ($result['type']=="资料") {
		# code...
		if(file_exists($path)){
			copy($y,$position);
			unlink($path);
		}
	}

	$stmt = $db->prepare("delete from check0 where name=?");
	$stmt->execute(array($name));

	$stmt = $db->prepare('select * from check0');
	$stmt->execute(array($name));
	$x=array();
	while($result= $stmt->fetch(PDO::FETCH_ASSOC))
		$x[] = $result;
	echo json_encode($x);
?>